<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <button>请求数据</button>
    <ul id="ul"></ul>

    <script>

        let data = []
        function getData() {
            return new Promise((resolve, reject) => {
                let xhr = new XMLHttpRequest();
                xhr.open('GET', 'https://mock.mengxuegu.com/mock/65a91543c4cd67421b34c898/movie/movieList', true);
                xhr.send();
                xhr.onreadystatechange = function () {
                    if (xhr.readyState == 4 && xhr.status == 200) {
                        console.log(JSON.parse(xhr.responseText).movieList)
                        resolve(JSON.parse(xhr.responseText).movieList)

                    }
                }
            })
        }

        function showList(data) {
            console.log(`拿到数据${data}`);

        }
        getData().then((res) => {
            showList(res)
        })

    </script>
</body>

</html>